package com.xxgc.eow.service.impl;

import com.xxgc.eow.entity.Collecttopic;
import com.xxgc.eow.mapper.CollecttopicMapper;
import com.xxgc.eow.service.ICollecttopicService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 收藏题目表 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-24
 */
@Service
public class CollecttopicServiceImpl extends ServiceImpl<CollecttopicMapper, Collecttopic> implements ICollecttopicService {

    @Resource
    private CollecttopicMapper collecttopicMapper;

    @Override
    public List<Collecttopic> getCollectTopicsByUserId(Integer userId) {
        return collecttopicMapper.getCollectTopicsByUserId(userId);
    }

    @Override
    public Integer addCollectTopic(Integer userId, Integer topicId) {
        return collecttopicMapper.insertCollectTopic(userId, topicId);
    }

    @Override
    public Integer removeCollectTopic(Integer userId, Integer topicId) {
        return collecttopicMapper.deleteCollectTopic(userId, topicId);
    }

    @Override
    public List<Collecttopic> getCollectTopicsLimit(Integer pageNum, Integer pageSize) {
        return collecttopicMapper.getAllCollectTopicsLimit((pageNum-1)*pageSize, pageSize);
    }

    @Override
    public Integer getCount() {
        return collecttopicMapper.selectCount();
    }
}
